package com.education.service.impl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.education.dao.MexamDao;
import com.education.model.ExamMessageModel;
import com.education.service.QueryExamPage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @author 信息服务层
 *
 */
@Service
public class QueryExamPageImpl implements QueryExamPage {

    /**
     * 注入接口
     */
    @Autowired
    private MexamDao mxdao;

    @Override
    public PageInfo<ExamMessageModel> pagenow(Integer pageNo, Integer pageSize) throws Exception {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 15 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<ExamMessageModel> list = mxdao.queryExam();
        PageInfo<ExamMessageModel> page = new PageInfo<>(list);
        System.out.println(page);
        return page;
    }

    @Override
    public PageInfo<ExamMessageModel> getExamMessageBy(Integer teacherId, Integer pageNo, Integer pageSize) throws Exception {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 15 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        return new PageInfo<>(mxdao.getExamMessageBy(teacherId));
    }

    @Override
    public void addexam(ExamMessageModel el) throws Exception {
        mxdao.addResource(el);
    }

    @Override
    public int deleup(Integer eid){

        return mxdao.deletExam(eid);
    }

    @Override
    public int cancelExam(ExamMessageModel em) {
        return mxdao.cancelExam(em);
    }

}
